namespace SinaFinanceBaseClassLibrary
{
    using System;
    using System.IO;
    using System.Net;
    using System.Runtime.CompilerServices;
    using System.Text;

    public class DB_SinaConnectHelp
    {
        private EventHandler downloadCompleted;

        public event EventHandler DownloadCompleted
        {
            [MethodImpl(MethodImplOptions.Synchronized)] add
            {
                this.downloadCompleted = (EventHandler)Delegate.Combine((Delegate)this.downloadCompleted, (Delegate)value);
            }
            [MethodImpl(MethodImplOptions.Synchronized)] remove
            {
                this.downloadCompleted = (EventHandler)Delegate.Remove((Delegate)this.downloadCompleted, (Delegate)value);
            }
        }

        public void GetXML(string _URL)
        {
            WebClient client = new WebClient();
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(this.wc_OpenReadCompleted);
            client.OpenReadAsync(new Uri(_URL));
        }

        private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                if (this.downloadCompleted != null)
                {
                    this.downloadCompleted(null, (EventArgs)null);
                }
            }
            else
            {
                StreamReader reader = new StreamReader(e.Result, Encoding.UTF8);
                string str2 = reader.ReadToEnd().ToString();
                if (this.downloadCompleted != null)
                {
                    this.downloadCompleted(str2, (EventArgs)null);
                }
            }
        }
    }
}
